package cn.zz.veggie.web.types.dto.mgmt.order;

import com.fasterxml.jackson.annotation.JsonIgnore;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;

/**
 * @author zhongq
 * @since 2024/6/3
 */
public class MgmtOrderItemDto {
	@NotNull
	@Positive
	private Integer productId;
	@NotNull
	@Positive
	private Integer quantity;
	@NotNull
	@PositiveOrZero
	private Integer shipped;
	@NotNull
	@Positive
	private Integer quote;

	private String remark;
	// ignore
	@JsonIgnore
	private Integer amount;

	public Integer calcAmount() {
		if (amount == null) {
			amount = (int) Math.round((shipped * quote) / 10.0D);
		}
		return amount;
	}

	// getter and setter
	public Integer getProductId() {
		return productId;
	}

	public void setProductId(Integer productId) {
		this.productId = productId;
	}

	public Integer getQuantity() {
		return quantity;
	}

	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public Integer getShipped() {
		return shipped;
	}

	public void setShipped(Integer shipped) {
		this.shipped = shipped;
	}

	public Integer getQuote() {
		return quote;
	}

	public void setQuote(Integer quote) {
		this.quote = quote;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}